<?php
$mode		= $this->uri->segment(3);

if ($mode == "edt" || $mode == "act_edt") {
	$act		= "act_edt";
	$idp		= $datpil->id;
	$no_agenda	= $datpil->no_agenda;
	$kode		= $datpil->kode;
	$dari		= $datpil->tujuan;
	$no_surat	= $datpil->no_surat;
	$tgl_surat	= $datpil->tgl_surat;
	$uraian		= $datpil->isi_ringkas;
	$ket		= $datpil->keterangan;
	$kirim_ke		= $datpil->kirim_ke;


} else {
	$act		= "act_add";
	$idp		= "";
	$no_agenda	= "";
	$kode		= "";
	$dari		= "";
	$no_surat	= "";
	$tgl_surat	= "";
	$uraian		= "";
	$ket		= "";
	$kirim_ke		= "";
}


?>
<div class="navbar navbar-inverse">
	<div class="container" style="z-index: 0">
		<div class="navbar-header">
			<span class="navbar-brand" href="#">Surat Keluar</span>
		</div>
	</div><!-- /.container -->
</div><!-- /.navbar -->

	<form action="<?=base_URL()?>surat_keluar/surat_keluar/<?php echo $act; ?>" method="post" accept-charset="utf-8">

	<input type="hidden" name="idp" value="<?php echo $idp; ?>">

	<div class="row-fluid well" style="overflow: hidden">

	<div class="col-lg-6">
		<table width="100%" class="table-form">
		<?php
			if ($this->session->userdata('admin_level')=='TU'){
				echo '<tr><td width="20%">No. Agenda</td><td><b><input type="text" name="no_agenda"  value="" style="width: 100px" class="form-control"></b></td></tr>';
			}
		?>
		<!--<tr><td width="20%">No. Agenda</td><td><b><input type="text" name="no_agenda"  value="" style="width: 100px" class="form-control"></b></td></tr>-->
		<tr><td width="20%">Tujuan Surat</td><td><b><input type="text" name="dari"  value="<?php echo $dari; ?>" id="dari" style="width: 400px" class="form-control"></b></td></tr>
		<tr><td width="20%">Nomor Surat</td><td><b><input type="text" name="no_surat"  value="<?php echo $no_surat; ?>" style="width: 300px" class="form-control"></td></tr>
		<tr>
			<td width="20%">Approval</td>
			<td>
			<?php
			/*
			if (($level_user=='Subdit') || ($level_user=='Sie') ){
				if ($mode == "edt" || $mode == "act_edt") {

					foreach ($reff_unit->result() as $row) {
						echo '<div class="checkbox">'
					    	.'<label>';
					    $check_kpd = '';
						foreach ($get_status_disposisi->result() as $row_sd) {
							if ($row_sd->kd_unit==$row->kd_unit){
								$check_kpd = 'checked';

							}

						}

						echo '<input type="checkbox" name="kpd_yth[]" value="' . $row->id .  '"' . $check_kpd . '> ' . $row->username . '';


					    echo '</label>'
					  		.'</div>';
					}

				}else{
					foreach ($reff_unit->result() as $row) {
						echo '<div class="checkbox">'
					    	.'<label>'
					      	.'<input type="checkbox" name="kpd_yth[]" value="' . $row->id . '"> ' . $row->username . ''
					    	.'</label>'
					  		.'</div>';
					}
				}
			}else{
				if (($mode == "edt" || $mode == "act_edt") && (isset($get_status_disposisi))) {

					foreach ($reff_unit->result() as $row) {
						echo '<div class="checkbox">'
					    	.'<label>';
					    $check_kpd = '';
					    foreach ($get_status_disposisi->result() as $row_sd) {
							if ($row_sd->kd_unit==$row->kd_unit){
								$check_kpd = 'checked';

							}

						}
						echo '<input type="checkbox" name="kpd_yth[]" value="' . $row->kd_unit .  '"' . $check_kpd . '> ' . $row->nm_unit . '';


					    echo '</label>'
					  		.'</div>';
					}

				}else{
					foreach ($reff_unit->result() as $row) {
						echo '<div class="checkbox">'
					    	.'<label>'
					      	.'<input type="checkbox" name="kpd_yth[]" value="' . $row->kd_unit . '"> ' . $row->nm_unit . ''
					    	.'</label>'
					  		.'</div>';
					}
				}
			}*/

			?>

			<select name="kirim_ke" class="form-control">
				<?php
					$d['value'] = $kirim_ke;
					echo $this->mdl_reff_unit->get_user_reff_unit($d);
				?>

			</select>
			</td>
		</tr>

		</table>
	</div>

	<div class="col-lg-6">
		<table width="100%" class="table-form">
			<tr><td width="20%">Kode Klasifikasi</td><td><b><input type="text" name="kode"  value="<?php echo $kode; ?>" id="kode_surat" style="width: 100px" class="form-control"></b></td></tr>
			<tr><td width="20%">Tanggal Surat</td><td><b><input type="text" name="tgl_surat"  value="<?php echo $tgl_surat; ?>" id="tgl_surat" style="width: 100px" class="form-control"></b></td></tr>
			<!-- <tr><td width="20%">File Surat (Scan)</td><td><b><input type="file" name="file_surat" class="form-control" style="width: 200px"></b></td></tr> -->
			<tr><td width="20%">Keterangan</td><td><b><input type="text" name="ket"  value="<?php echo $ket; ?>" style="width: 400px" class="form-control"></b></td></tr>
		</table>
	</div>

	<table width="100%" class="table-form">
		<tr>
			<td>Isi Surat</td>
		</tr>
		<tr>
			<td><b><textarea name="uraian"  rows="30"  class="form-control"><?php echo $uraian; ?></textarea></b></td>
		</tr>
		<tr><td colspan="2">
		<br><button type="submit" class="btn btn-primary">Simpan</button>
		<a href="<?=base_URL()?>surat_keluar/surat_keluar" class="btn btn-success">Kembali</a>
		</td></tr>
	</table>


	</div>

	</form>